package longshu.srpc.test.server;

import lombok.extern.slf4j.Slf4j;
import longshu.srpc.SimpleRpcProtocol;
import longshu.srpc.server.impl.SimpleRpcAcceptor;
import longshu.srpc.server.impl.SimpleRpcServer;
import longshu.srpc.test.api.HelloService;
import longshu.srpc.test.api.UserService;

import java.util.concurrent.TimeUnit;

/**
 * 服务端测试
 *
 * @author LongShu 2017/12/03
 */
@Slf4j
public class RpcProvider {

    public static void main(String[] args) throws Exception {
        SimpleRpcProtocol.register();
        SimpleRpcAcceptor rpcAcceptor = new SimpleRpcAcceptor(SimpleRpcProtocol.PROTOCOL, "127.0.0.1", 8090);
        SimpleRpcServer rpcServer = new SimpleRpcServer(rpcAcceptor);

        HelloService helloService = new HelloServiceImpl();

        rpcServer.export(HelloService.class, helloService);
        rpcServer.export(HelloService.class, HelloServiceImpl.class);
        rpcServer.export(UserService.class, UserServiceImpl.class);

        rpcServer.start();

        TimeUnit.SECONDS.sleep(150);
        rpcServer.stop();
    }

}
